<template>
  <view class="flex-col page">
    <view class="flex-col items-center section_1 ">
      <view class="flex-col section_2">
        <view class="flex-row group">
          <text class="text">合同工期</text>
          <image @click="Back()"
            :src="imgUrl+'16557826955471526569.png'"
            class="image"
          />
        </view>
        <view class="flex-col group_1">
          <view class="flex-col items-center button"><view class="text_1">
			<u-input placeholder="请输入合同工期" border="none" v-model="smark"> </u-input>
		   </view></view>
          <text class="text_2">建议该工期与合同相符</text>
          <view class="flex-row group_2">
            <view class="flex-col items-center text-wrapper"><text class="text_3" @click="Back()">取消</text></view>
            <view class="flex-col items-center text-wrapper_1" @click="getdata"><text class="text_4">确认</text></view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    components: {},
    data() {
      return {
		  imgUrl:this.$IMG_URL,
		  smark:'',
		  inspectionId:'',
		  orderid:0,
	  };
    },
	onLoad(option) {
		this.inspectionId = option.id
		this.orderid=option.orderid;
		this.getInfo(this.orderid);
	},
    methods: {
		Back(){
			//uni.navigateBack()//默认delta:1
			uni.navigateBack({
				delta:1,//返回层数，2则上上页
			})
		},
		getInfo(orderid){
			
			this.$http('mine.ordersEXL',{
				ordersId:orderid
			}).then(r=>{
			   if(r.code==200)
			   {
				   this.smark=r.data.inspection.contractDuration
			   }
			})
		},
		getdata(){
			if(this.smark == '') {
				return this.$u.toast('请输入合同工期')
			}
			this.$http('explan.saveContractDuration',{
				inspectionId:this.inspectionId,
				contractDuration:this.smark
			}).then(res=>{
				if(res.code==200){
					let  pageNum = 2
						let pages = getCurrentPages(); // 当前页面
						let beforePage = pages[pages.length - pageNum]; // 前一个页面
						console.log(beforePage);
						uni.navigateBack({
						 success: function() {
						beforePage.$vm.init(); 
						}
													
					  }
					);
				}
			})
		}
	},
  };
</script>

<style scoped lang="scss">
  .page {
    background-color: #ffffffff;
    width: 100vw;
    height: 100vh;
  }
  .section_1 {
	  
	  height: 100%;
	display: flex;
	align-items: center;
	flex-direction: column;
	justify-content: center;
    background-color: #00000080;
  }
  .section_2 {
    padding: 14px 15px 16px;
    background-color: #ffffff;
    border-radius: 8px;
  }
  .group {
    padding: 0 1.25px;
  }
  .group_1 {
    margin-top: 29.25px;
  }
  .text {
    margin-left: 82.25px;
    color: #333333;
    font-size: 18px;
    font-family: '.AppleSystemUIFont';
  }
  .image {
    margin-left: 69.25px;
    margin-top: 7.75px;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
  }
  .button {
    padding: 11px 0 16.5px;
    background-color: #f6f7f9;
    border-radius: 22px;
    width: 240px;
  }
  .text_2 {
    margin-top: 10.5px;
    align-self: center;
    color: #ff371d;
    font-size: 11px;
    font-family: '.AppleSystemUIFont';
  }
  .group_2 {
    margin-top: 23.5px;
    padding: 0 1px;
  }
  .text_1 {
    color: #bfbfbf;
    font-size: 14px;
    font-family: '.AppleSystemUIFont';
  }
  .text-wrapper {
    padding: 7px 0 12.5px;
    background-color: #f6f7f9;
    border-radius: 18px;
    width: 111px;
    height: 36px;
  }
  .text-wrapper_1 {
    margin-left: 16px;
    padding: 7px 0 12.5px;
    background-color: #1a76f2;
    border-radius: 18px;
    width: 111px;
    height: 36px;
  }
  .text_3 {
    color: #333333;
    font-size: 14px;
    font-family: '.AppleSystemUIFont';
  }
  .text_4 {
    color: #ffffff;
    font-size: 14px;
    font-family: '.AppleSystemUIFont';
  }
</style>